package com.lanou.controller;


import com.lanou.service.MQservice;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;


@Controller
public class MQController {

    @Resource
    private MQservice mQservice;


    @RequestMapping("/producer")
    public String producer(){
        return "producer";
    }

    @RequestMapping("/consumer")
    public String consumer(Model model){

        model.addAttribute("msg" ,mQservice.receiveMsg());


        return "consumer";
    }

    @RequestMapping("/send")
    public String sendMsg(String message){

        mQservice.sendMessage(message);

        return "redirect:consumer";

    }


}
